﻿using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class LabelRecord : BiffRecord
    {
        private CellStructure _cell;
        private XLUnicodeString st;

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            this._cell = new CellStructure();
            _cell.Read(context.Reader);
            this.st = new XLUnicodeString();
            st.Read(context.Reader);
        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.Label; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            _cell.Write(context.Writer);
            st.Write(context.Writer);
        }
        struct CellStructure
        {
            private ushort row;
            private ushort column;
            private ushort ixfe;

            public void Read(BinaryReader reader)
            {
                this.row = reader.ReadUInt16();
                this.column = reader.ReadUInt16();
                this.ixfe = reader.ReadUInt16();
            }

            public void Write(BinaryWriter writer)
            {
                writer.Write(row);
                writer.Write(column);
                writer.Write(this.ixfe);
            }
        }
    }
}